<?php

declare(strict_types=1);

namespace app\admin\validate\auth;

use sheep\validate\Backend;

class Admin extends Backend
{
    // TODO token可配置是否自动续期 默认不自动续期
    protected $rule = [
        'account' => 'require|alphaDash|length:4,12|unique:admin',
        'nickname' => 'require|chsDash|length:2,10|unique:admin',
        'mobile' => 'mobile|unique:admin',
        'avatar' => 'require',
        'email' => 'email|unique:admin',
        'password' => 'require|length:6,16',
        'role_id' => 'require|integer'
    ];

    protected $message  =   [
        'account.require'     => '账号必须填写',
        'account.alphaDash'     => '账号只能是字母和数字，下划线_及破折号-',
        'account.length'     => '账号长度必须在 5-12 位',
        'account.unique'     => '账号已被占用',
        'nickname.require'     => '昵称必须填写',
        'nickname.chsDash'     => '角色名称只能是汉字、字母、数字和下划线_及破折号-',
        'nickname.length'     => '昵称长度必须在 2-10 位',
        'nickname.unique'     => '昵称已被占用',
        'mobile.mobile'     => '手机号格式不正确',
        'mobile.unique'     => '手机号已被占用',
        'avatar.require'     => '头像必须上传',
        'email.email'     => '邮箱格式不正确',
        'email.unique'     => '邮箱已被占用',
        'password.length'     => '密码长度必须在 6-16 位',
        'role_id.require'     => '必须选择所属角色',
        'role_id.integer'     => '所属角色格式不正确',
    ];


    protected $scene = [
        'add'  =>  ['account', 'nickname', 'mobile', 'password', 'avatar', 'email', 'role_id'],
    ];
}
